package com.work.user.dao;

import com.github.pagehelper.Page;
import com.work.user.pojo.Menu;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.Set;

public interface MenuMapper extends Mapper<Menu> {

    //查询中间表，查看与角色有关系的权限
    @Select("select m.* from t_menu m ,t_role_menu rm where m.id = rm.mid and rm.rid = #{id}")
    public Set<Menu> findByRoleId(int id);

    //查询中间表
    @Select("select count(*) t_menu m , t_role_menu rm where m.id = rm.mid and rm.mid = #{id}")
    int findByCount(int id);

    //分页查询条件
    @Select("<script>select * from t_menu where <if test='value !=null'>" +
            "name like '%' #{value} '%' or id keyword '%' #{value} '%'</if></script>")
    public Page<Menu> selectByCondition(String queryString);

}
